jsx3.Class.defineClass(
	"ux.cdb.admin.dataautomate.DateUpdater",
	ux.cdb.admin.dataautomate.GenericUpdater, null,
	function (block) {

		/**
		* instance initializer
		* @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
		* @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
		*/
		block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
			//call constructor for super class (the super expects the name of the object and the function that it is an instance of)
			this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
		};
		
		block.prototype.onAfterAttach = function(){
			var format = this.getDescendantOfName("dateValue").getFormat();
			if(format != null && format != ''){
				this.getDescendantOfName("dateValue").setFormat('yyyy-MM-dd');
			}
            this.jsxsuper();
		}
		
		block.prototype.applyData = function(data) {
			var me = this;
			var text = data[this.uxdataatt];
            if(text) {
                if(text instanceof Date) {
                    this.getDescendantOfName("dateValue").setDate(text,true);
                } else {
                    var strFormat = this.getDescendantOfName("dateValue").getFormat();
                    var format = new jsx3.util.DateFormat(strFormat);
                    this.getDescendantOfName("dateValue").setDate(format.parse(text),true);
                }
            }
		};
		
		block.prototype.extractData = function(){
			return this.getDescendantOfName("dateValue").getDate();
		};

		block.prototype._validateFailedUI = function(failed, message){
			var objText = this.getDescendantOfName("dateValue");
            var input = objText.getRendered().childNodes[0].childNodes[0];
            if(!input) return;
			
			if(failed === true){
				input.style.backgroundColor = ux.megatron.Main.getServer().getDynamicProperty("@cdb@Validation Failed BGColor");
                input.title = (message) ? message : "";
                objText.setBackgroundColor(ux.megatron.Main.getServer().getDynamicProperty("@cdb@Validation Failed BGColor"));
				objText.setTip((message) ? message : "");
			}else{

				if(objText.getEnabled() == jsx3.gui.Form.STATEDISABLED) {
					objText.setBackgroundColor(jsx3.gui.Form.DEFAULTDISABLEDBACKGROUNDCOLOR, true);
                    input.style.backgroundColor = jsx3.gui.Form.DEFAULTDISABLEDBACKGROUNDCOLOR;
				} else {
					objText.setBackgroundColor("#FFFFFF", true);
                    input.style.backgroundColor = "#FFFFFF";
				}
				objText.setTip("");
                input.title = "";
			}
		};

        block.prototype.setAsTriggerField = function() {
            if(this.get("dateValue")) {
                this.get("dateValue").subscribe(jsx3.gui.Interactive.CHANGE, this, function() {
                    var fieldName = this.getName();
                    var that = this;
                    setTimeout(function() {
                        if(that.provider.onTriggerFieldChange) {
                            that.provider.onTriggerFieldChange(fieldName);
                        }
                    }, 10);
                });
            }
        };

        block.prototype.focusField = function() {
            if(this.get("dateValue")) {
                this.get("dateValue").focus();
            }
        };

	});